package com.sgb.kjwl.view.ui.activity.material.hall;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import androidx.annotation.Nullable;
import androidx.databinding.DataBindingUtil;

import com.sgb.kjwl.AppActivity;
import com.sgb.kjwl.R;
import com.sgb.kjwl.databinding.ActivityNewDemandHallBinding;
import com.sgb.kjwl.view.ui.adapter.CommPagerAdapter2;
import com.swgk.core.view.entity.MenuEntity;
import com.sgb.jicai.view.fragment.JiCaiXuFangFaQiFragment;
import com.sgb.kjwl.view.ui.fragment.material.DemandHallFragment;
import com.sgb.kjwl.view.ui.fragment.pick.PickHallBidingFragment;
import com.swgk.core.base.BaseFragment;
import com.swgk.core.base.BaseViewModel;

import java.util.ArrayList;
import java.util.List;

public class NewDemandHallActivity extends AppActivity {


    private ActivityNewDemandHallBinding binding;
    private CommPagerAdapter2 goodsFragmentPagerAdapter;
    private ArrayList<BaseFragment> fragmentList = new ArrayList<>();
    ;
    private List<MenuEntity> table = new ArrayList<>();
    private List<String> names = new ArrayList<>();

    public static void start(Context context) {
        Intent intent = new Intent();
        intent.setClass(context, NewDemandHallActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
        context.startActivity(intent);
    }


    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    protected void initView() {
        binding = DataBindingUtil.setContentView(NewDemandHallActivity.this, R.layout.activity_new_demand_hall);
        binding.setViewModel(new BaseViewModel());
        names.add("客户询价");
        names.add("招标大厅");
        names.add("竞价采购");
        names.add("需方集采");
        names.add("企业专项");

        for (int i = 0; i < names.size(); i++) {
            MenuEntity entity = new MenuEntity(String.valueOf(i), names.get(i));
            table.add(entity);
//            fragmentList.add(XufangFaQiFragment.newInstance());
        }
        //每个Fragment传1显示搜索，传其他隐藏
        //客户询价
        fragmentList.add(DemandHallFragment.newInstance(0));
        //商品招标 PickSigningUplistActivity(已改造实现同步)
        //fragmentList.add(NewPickSigningUpListFragment.newInstance("1"));
        //招标大厅  PickHallBidingFragment(已改造实现同步)
        fragmentList.add(PickHallBidingFragment.newInstance("1"));
//        fragmentList.add(PickHallFragment.newInstance("1"));
        //招标预告 PickNoticeActivity(已改造实现同步)
        //fragmentList.add(PickNoticeFragment.newInstance("1"));
        //竞价集购  PickBiddingListActivity(已改造实现同步)
        fragmentList.add(NewPickBiddingListFragment.newInstance("1"));
        //需方集采 XuFangFaQiActivity(已改造实现同步)
//        fragmentList.add(XufangFaQiFragment.newInstance("1"));
        fragmentList.add(JiCaiXuFangFaQiFragment.newInstance(1,"1","1","1",""));//新增type区分是否加载集采方式
        //企业专项 CentralizedTypeActivity(已改造实现同步)
//        fragmentList.add(NewCentralizedMiningFragment.newInstance("1"));
        fragmentList.add(JiCaiXuFangFaQiFragment.newInstance(1,"2","1","1",""));//新增type区分是否加载集采方式
//        fragmentList.add(CentralizedMiningFragment3.newInstance(0,1,"","3",1,"","1"));

        goodsFragmentPagerAdapter = new CommPagerAdapter2(getSupportFragmentManager(), fragmentList, table);
        binding.viewpager.setAdapter(goodsFragmentPagerAdapter);
        binding.tabLayout.setupWithViewPager(binding.viewpager);
        binding.viewpager.setCurrentItem(0);
    }

    @Override
    protected void init() {
        binding.ivBack.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.iv_back:
                finish();
                break;
        }
    }
}
